package com.henu.acmrating.utils;

import com.google.common.base.Splitter;

import java.util.Map;

public class StringUtils {
    public static String getParam(String url, String name) {
        String params = url.substring(url.indexOf("?") + 1, url.length());
        Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(params);
        return split.get(name);
    }

    /*
    一、格式错误 Presentation error
    二、编译错误 Compile Error
    三、运行错误 Runtime Error
    四、答案错误 Wrong Answer
    五、时间超限 Time Limit Exceeded
    六、内存超限 Memory Limit Exceeded
    答案正确 Accepted
    输出超限 Output Limit Exceeded
     */
    private static String[] zh = {"格式错误", "编译错误", "运行错误", "答案错误", "时间超限", "内存超限", "答案正确", "输出超限"};
    private static String[] en = {"Presentation error", "Compile Error", "Runtime Error", "Wrong Answer", "Time Limit Exceeded", "Memory Limit Exceeded", "Accepted", "Output Limit Exceeded"};

    public static String ch2english(String str) {
        String result = "Wrong Answer";
        for(int i = 0; i < zh.length; i++) {
            if(zh[i].equals(str)) {
                result = en[i];
                break;
            }
        }
        return result;
    }
}
